package cate.game.play.skill.passive.gem;

import cate.common.util.XT;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.ActionCtx;
import cate.game.play.skill.FighterCD;
import cate.game.play.skill.passive.PassiveHandler;
import easy.java.struct.ref.DoubleRef;

/**
 * 受到致死伤害时 25% 概率触发，无法行动和成为受击目标，结束时恢复 17% 生命值，冷却 6 回合
 */
public class 金身PH extends PassiveHandler {

	private int 概率;

	private int 冷却回合;

	private int buff;

	//概率=2500&冷却回合=6&buff=??
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		概率 = args.getInt("概率", 0);
		冷却回合 = args.getInt("冷却回合", 0);
		buff = args.getInt("buff", 0);
	}

	private int lastRound;

	@Override
	public void adjustDeadlyDamage(ActionCtx action, Fighter actor, int reason, DoubleRef doubleRef) {
		if(FighterCD.inCD(lastRound, 冷却回合,action.getRound().index)){
			return;
		}
		if (!XT.chance(概率)) {
			return;
		}
		lastRound = action.getRound().index;
		doubleRef.v = 0;
		skill.owner.buff.tryAddByTid(action, buff);
	}
}
